import {request} from '@utils/http';
import { HospitalSetItem, ReqAddHospitalSetParams, ReqGetHospitalSetParams, ReqGetHospitalSetResponse, ReqUpdateHospitalSetParams } from './model/hospitalSetTypes';

//发送请求获取医院设置的列表信息
export function reqGetHospitalSet({page, limit, ...args}: ReqGetHospitalSetParams){
  // request()   axios()   axios.get()
  return request.get<any, ReqGetHospitalSetResponse>(`/admin/hosp/hospitalSet/${page}/${limit}`, {
    params: args
  });
}

/**
 * 
 * @param hospital  医院设置的相关信息 
 * @returns Promise<null>
 */
export function reqAddHospitalSet(hospital: ReqAddHospitalSetParams){
  return request.post('/admin/hosp/hospitalSet/save', hospital);
}


/**
 * 
 * @param id 获取医院信息的 id 编号
 * @returns Promise<HospitalSetItem>
 */
export function reqGetHospitalSetById(id: string){
  return request.get<any, HospitalSetItem>(`/admin/hosp/hospitalSet/get/${id}`);
}

/**
 * 
 * @param hospital 医院设置的信息对象  注意: 其中包含 id 属性
 * @returns Promise<null>
 */
export function reqUpdateHospitalSet(hospital: ReqUpdateHospitalSetParams){
  return request.put<any, null>('/admin/hosp/hospitalSet/update', hospital);
}

/**
 * 
 * @param id 医院设置信息的 id
 * @returns Promise<null>
 */
export function reqRemoveHospital(id: string){
  return request.delete(`/admin/hosp/hospitalSet/remove/${id}`)
}

/**
 * 
 * @param idList 要删除医院设置的 id 数组
 * @returns Promise<null>
 */
export function reqBatchRemoveHospitalSet(idList: number[]){
  return request.delete('/admin/hosp/hospitalSet/batchRemove', {
    data: idList
  })
}